﻿using IDAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class BaseDAL<T> : IBaseDAL<T> where T : class
    {
        public BaseDAL(MyDbContext db)
        {
            Db = db;
        }

        public MyDbContext Db { get; }

        public async Task<int> AddAsync(T t)
        {
            await Db.Set<T>().AddAsync(t);
            return await Db.SaveChangesAsync();
        }
        public IQueryable<T> QueryAsync()
        {
            return Db.Set<T>();
        }

        public async Task<int> UpdateAsync(List<T> t)
        {
            Db.Set<T>().UpdateRange(t);
            return await Db.SaveChangesAsync();
        }
    }
}
